import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import "../Common/Compoments"

Rectangle
{
    id: m_loginPanel
    width: {
        if ( m_nPlatForm == 1)
        {
            return parent.width * 0.2 < 300 ? 300:parent.width * 0.2
        }
        else{
            if ( parent.width < parent.height )
            {
                return parent.width * 0.6
            }
            else
            {
                return parent.width * 0.25 < 350 ? 350:parent.width * 0.25
            }
        }
    }
    height: width * 0.6

    x: (parent.width - width) / 2
    y: (parent.height - height ) / 2

    color: g_Colors.m_cNullBackgroundColor
    property real  m_fFontSize : 0.5
    property double m_itemHeightConffict: 0.22
    property double m_itemWidthConffict: 1

    signal signalLogin();
    signal signalUseHistory();

    function otherAreaEvent(){
        //        historyLoginList.visible = false
    }

    function clearPwd()
    {
        pwdinput.text = ""
    }

    MouseArea
    {
        anchors.fill: parent
        hoverEnabled: true
    }

    Flow
    {
        id : inputLayout
        anchors.fill: parent
        spacing: height * 0.09

        //编号输入框
        Rectangle
        {
            width: parent.width*m_itemWidthConffict
            height: parent.height *m_itemHeightConffict
            border.width: 1
            border.color: g_Colors.m_cTextFieldBorderColor
            radius: 6

            Image
            {
                height: parent.height * 0.6
                width: height
                x: parent.height * 0.2
                y: x
                source: setting.m_strLoaderPath + "/loader_institution_Normal.png"
                anchors.margins: 20
            }
            LQTextField
            {
                placeholderText: g_Language.m_strLoaderInputId //"请输入编号"
                id: institutioninput
                height: parent.height
                width: parent.width - height
                x: height
                style:TextFieldStyle{
                    background:Rectangle{
                        color: g_Colors.m_cNullBackgroundColor
                        implicitWidth: parent.width
                        implicitHeight: parent.height
                    }
                }
                textColor: g_Colors.m_cLoginPanelInputText
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: height * m_fFontSize
                focus: false
                selectByMouse: true
                text: ""
                clip: true
            }
        }

        //用户名输入框
        Rectangle
        {
            id: usernameinput
            width: parent.width * m_itemWidthConffict
            height: parent.height *m_itemHeightConffict
            border.width: 1
            border.color: g_Colors.m_cTextFieldBorderColor
            radius: 6

            Image
            {
                height: parent.height*0.6
                width: height;
                x: parent.height* 0.2
                y: x
                source: setting.m_strLoaderPath + "/loader_user_Normal.png"
                anchors.margins: 20
            }
            LQTextField
            {
                placeholderText: g_Language.m_strLoaderUserName//"请输入用户名"
                id: username

                height: parent.height
                width: parent.width - height * 2
                x: height

                textColor:g_Colors.m_cLoginPanelInputText
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: height * m_fFontSize
                focus: false
                selectByMouse: true
                text: ""
                clip: true

                style:TextFieldStyle{
                    background:Rectangle{
                        color: g_Colors.m_cNullBackgroundColor
                        implicitWidth: parent.width
                        implicitHeight: parent.height
                    }
                }
            }
        }

        //密码输入框
        Rectangle
        {
            width: parent.width * m_itemWidthConffict
            height: parent.height * m_itemHeightConffict
            color: g_Colors.m_cLoginPanelInputBackground //"#dddddd"
            border.width: 1
            border.color: g_Colors.m_cTextFieldBorderColor
            radius: 6

            Image
            {
                height: parent.height*0.6
                width: height;
                x: parent.height* 0.2
                y: x
                source: setting.m_strLoaderPath + "/loader_password_Normal.png"
                anchors.margins: 20
            }
            LQBaseTextInput
            {
                id: pwdinput

                height: parent.height
                width: parent.width - height*1.5
                x: parent.height*1.2

                verticalAlignment: Text.AlignVCenter
                echoMode : TextInput.Password
                font.pixelSize: height * m_fFontSize
                focus: false
                selectByMouse: true
                text: ""
                clip: true
            }
        }

        //记住密码,自动登录相关
        Rectangle
        {
            id: checkss
            width: parent.width * 1.1
            height: parent.height *m_itemHeightConffict

            property int fontSize: height * 0.44
            color: g_Colors.m_cNullBackgroundColor

            Flow
            {
                anchors.fill: parent
                anchors.leftMargin: 0
                spacing: m_bShowLoginPhoneLogo ? (inputLayout.width - passowrdCheck.width*2-40): parent.width * 0.07

                Item
                {
                    height: parent.height
                    width: passowrdCheck.width

                    LQRadioButton
                    {
                        id: passowrdCheck
                        outterNormalColor: g_Colors.m_cLoginPanelRadioNormal
                        innerrColor: g_Colors.m_cLoginPanelRadioChecked
                        radiobuttonNormalColor: g_Colors.m_cLoginPanelRadioBorder
                        radiobuttonHoveredColor: g_Colors.m_cLoginPanelRadioBorder
                        radiobuttonPressedColor: g_Colors.m_cLoginPanelRadioBorder
                        radioBorderWidth: 2
                        radioButtonText: g_Language.m_strLoaderRemberPwd//"记住密码"
                        innerOffset: radioButtonWidth - 4;
                        radioRadius:2
                        textpixSise: checkss.fontSize
                        height: parent.height*0.7
                        radioButtonWidth: height*0.7
                        radioButtonHeight: height*0.7
                        y: (parent.height - height ) / 2
                        checked: false
                    }
                }

                Item
                {
                    height: parent.height
                    width:autologin.width //parent.width * 0.13

                    LQRadioButton
                    {
                        id: autologin
                        outterNormalColor: g_Colors.m_cLoginPanelRadioNormal
                        innerrColor: g_Colors.m_cLoginPanelRadioChecked
                        radiobuttonNormalColor: g_Colors.m_cLoginPanelRadioBorder
                        radiobuttonHoveredColor: g_Colors.m_cLoginPanelRadioBorder
                        radiobuttonPressedColor: g_Colors.m_cLoginPanelRadioBorder
                        radioBorderWidth:2
                        radioButtonText: g_Language.m_strLoaderAutoLogin//"自动登录"
                        innerOffset:radioButtonWidth - 4;
                        radioRadius:2
                        textpixSise:checkss.fontSize
                        height: parent.height*0.7
                        radioButtonWidth: height*0.7
                        radioButtonHeight: height*0.7
                        y: (parent.height - height ) / 2
                        checked: false
                    }
                }

                Item
                {
                    height: parent.height
                    width: modifyPwd.width
                    visible: !m_bShowLoginPhoneLogo

                    LQBaseText
                    {
                        id: modifyPwd
                        text: g_Language.m_strLoaderModifyPwd //"修改密码"
                        color: g_Colors.m_cLoginPanelModifyPassword
                        y: (parent.height - height ) / 2
                        font.pixelSize: checkss.fontSize
                    }

                    MouseArea
                    {
                        anchors.fill: parent
                        onClicked:
                        {
                        }
                    }
                }
            }
        }


        //登录按钮
        LQLoaderButton
        {
            id: btn_login

            width: parent.width * m_itemWidthConffict
            height: parent.height * m_itemHeightConffict

            text : g_Language.m_strLoaderBtnLogin //"登录"
            onSignalClicked:
            {
                signalLogin();
            }
        }
    }
}
